import * as mongoose from 'mongoose';
import db from './../core/mongodb';

/**
 * 工会 实体类
 */
let unionSchema: mongoose.Schema = new mongoose.Schema(
    {
        icon: String,  //图标
        title: String, //表体
        responsible: [{ userName: String, tel: String }],//负责人列表
        activityDate: String,//活动时间
        tel: String //电话
    }, { collection: 'union', timestamps: { createdAt: 'createDate', updatedAt: 'updateDate' } });
export interface Union extends mongoose.Document {
    icon: string;
    title: string;
    responsible: [{ userName: string, tel: string }];
    activityDate: string;
    tel: string;
}
export let unionModel = db.model<Union>('union', unionSchema);


/**
 * 工会简介 实体类
 * 图片，title，负责人，电话，创立时间 ，有可能还有口号
 */
let introduceSchema: mongoose.Schema = new mongoose.Schema(
    {
        unionId: String,  //工会 主键
        content: [{ img: String, text: String }], //表体
        title: String,
        responsible: [{ userName: String, tel: String }],//负责人列表,
        setDate: String, //创立时间
        slogan: String //口号 标语
    }, { collection: 'introduce', timestamps: { createdAt: 'createDate', updatedAt: 'updateDate' } });
export interface Introduce extends mongoose.Document {
    unionId: string;
    content: [{ img: string, text: string }];
    title: string;
    responsible: [{ userName: string, tel: string }];
    setDate: string;
    slogan: string;
}
export let introduceModel = db.model<Introduce>('introduce', introduceSchema);

/**
 * 工会活动 实体类
 */
let activitySchema: mongoose.Schema = new mongoose.Schema(
    {
        unionId: String,  //工会 主键
        title: String, //表体
        responsible: [{ userName: String, tel: String }],//负责人列表,
        activityDate: String,//活动时间
        content: String,//内容
        actImg: { img: String, text: String },
        isHistory: String //yes no
    }, { collection: 'activity', timestamps: { createdAt: 'createDate', updatedAt: 'updateDate' } });
export interface Activity extends mongoose.Document {
    unionId: string;
    title: string;
    responsible: [{ userName: string, tel: string }];
    activityDate: string;
    content: string;
    actImg: { img: string, text: string };
    isHistory: string;
}
export let activityModel = db.model<Activity>('activity', activitySchema);
